from datetime import datetime
from typing import List, Dict, Optional

from emi.bar.data import Interval
from emi.bar.db import BarSource
from emi.barx.data import BarX


class BarXDB(BarSource):
    """
      行情数据。
    """

    def set_default_interval(self,interval:Interval):
        assert interval is not None
        setattr(self,"_default_interval",interval)

    def get_default_interval(self)->Interval:
        return getattr(self,"_default_interval",Interval.DAILY)


    def get_bars_recently(self, symbol: str, time: datetime, count: int, interval: Interval = None, is_before=True,with_detail = True) -> List[BarX]:
        """
        返回time(包含当天）最近以前的bar行情数据:
        :interval 行情频率，为None时取默认值：get_default_interval()
        """
        pass

    def get_bars_at_day(self, time: datetime, interval: Interval = None,with_detail = True) -> Dict[str, BarX]:
        """
        获取某一天的所有数据:
        key : symbol。
        :interval 行情频率，为None时取默认值：get_default_interval()
        """
        raise NotImplementedError("未实现")

    def get_newest_datetime(self, symbol: str = None, interval=Interval.DAILY) -> Optional[datetime]:
        raise NotImplementedError("未实现")

    def get_newest_bar(self, symbol: str = None, interval=Interval.DAILY) -> Optional[BarX]:
        raise NotImplementedError("未实现")

    def get_oldest_datetime(self, symbol: str = None, interval=Interval.DAILY) -> Optional[datetime]:
        raise NotImplementedError("未实现")


    def get_symbol_list(self) -> List[str]:
        raise NotImplementedError("未实现")

    def size(self, symbol: str = None) -> int:
        raise NotImplementedError("未实现")